<!--
 * @Author: w_yy
 * @Date: 2023-03-20 10:42:20
 * @LastEditors: w_yy
 * @LastEditTime: 2023-03-20 11:13:28
 * @FilePath: \vue-project\src\views\List.vue
 * @Copyright: 2023 沈阳东软智睿放疗技术有限公司
 * @Descripttion: 该文件用于OIS系统。版权由东软智睿放疗技术有限公司所有
-->
<template>
  <!-- list 是源数据的数组，而 item 是迭代项的别名
    index  表示当前项的位置索引
  -->
  <div v-for="(item, index) in list" :key="index">
    <h1>{{ item.title }}</h1>
    <div>{{ item.patientName }}</div>
  </div>
  <div v-for="(value, key, index) in myObject" :key="index">
    {{ value }},{{ key }},{{ index }}
  </div>
</template>

<script>
import { reactive, toRefs } from "vue";
export default {
  name: "List",
  setup() {
    let dataInfo = reactive({
      list: [
        {
          title: "title1",
          patientName: "张三",
        },
        {
          title: "title2",
          patientName: "张三1",
        },
        {
          title: "title3",
          patientName: "张三2",
        },
      ],
      myObject: {
        title: "How to do lists in Vue",
        author: "Jane Doe",
        publishedAt: "2016-04-10",
      },
    });
    //作用域
    dataInfo.list.forEach((item, index) => {
      console.log(item);
      console.log(index);
    });
    return {
      ...toRefs(dataInfo),
    };
  },
};
</script>

<style>
</style>